package com.mhkj.base.itemInfo.item.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.mhkj.base.itemInfo.item.entity.Item;
import com.mics.core.system.base.repository.BaseRepository;

public interface ItemDao extends BaseRepository<Item>{
	/**
	 * 查询项目,按城市分组
	 * @return
	 */
	@Query("select t from Item t group by t.tSysNation.id")
	List<Item> getProvinceWithItem();
	
	
	@Query("select t from Item t where t.affiliatedCompanyId = :companyId")
	List<Item> getListItemByaffiliatedCompanyId(@Param("companyId") String companyId);
	
	/**
	 * 获取城市下的所有项目
	 * @param cityId
	 * @return
	 */
	@Query("select t from Item t where t.tSysNation.id = :cityId")
	List<Item> getItemWithCityId(@Param("cityId")Long cityId);

	/**
	 * 获取省份下的所有项目
	 * @param provinceId
	 * @return
	 */
	@Query("select t from Item t where t.tSysNation.parentId = :provinceId")
	List<Item> getItemWithProvinceId(@Param("provinceId")Long provinceId);

	/**
	 * 获取已经建立项目对应的省下城市
	 * @param provinceId 
	 * @return
	 */
	
	@Query("select t from Item t where t.tSysNation.parentId = :provinceId")
	List<Item> getCityWithProvince(@Param("provinceId")Long provinceId);

	
}
